﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using System.IO;
using System.ServiceModel.Channels;
using System.ServiceModel.Web;

namespace WebRole1
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebGet(UriTemplate = "ClientAccessPolicy.xml")]
        Message ProvidePolicyFile();

        [OperationContract]
        string login(string username, string password);

        [OperationContract]
        List<string> retrieveRoles(string username);

        # region image
        [OperationContract]
        string retrieveItemsList();

        [OperationContract]
        string uploadItem(string fileName, byte[] fileBytes);

        [OperationContract]
        string uploadFaceImage(string fileName, byte[] fileBytes);

        [OperationContract]
        byte[] searchAndretrieveImage(string txtSearch);

        [OperationContract]
        byte[] retrieveImage(string URL);

        //[OperationContract]
        //BlobStream searchAndretrieveItem(string txtSearch);

        //[OperationContract]
        //BlobStream retrieveItem(string URL);

        #endregion

        # region CRUD for table patient_faceImg

        [OperationContract]
        bool createPatient_faceImg(string patient, string path);

        [OperationContract]
        List<string> retrievePatient_faceImg(string patient);

        # endregion

        # region CRUD for exe

        [OperationContract]
        bool createEXE(string name, string path, string desc, int exeType, List<string> custKey);

        [OperationContract]
        List<EXE> retrieveAllEXE();

        [OperationContract]
        List<EXE> retrieveAllEXEofExeType(int exeType);

        [OperationContract]
        EXE retrieveEXE(int exeID);

        [OperationContract]
        List<string> retrieveTag(int exeID);

        [OperationContract]
        List<int> retrieveExeIDofTag(int joint);

        [OperationContract]
        List<EXE> retrieveExeofTag(int joint);

        # endregion

        #region CRUD for problem

        [OperationContract]
        bool updateProblem(int uid, int patientID, string joint, string problems, string description, int severity, string notes);

        /// <summary>
        /// update problem specifically for description, severity and notes
        /// </summary>
        /// <param name="joint"></param>
        /// <param name="patientID"></param>
        /// <param name="description"></param>
        /// <param name="severity"></param>
        /// <param name="notes"></param>
        /// <returns></returns>
        [OperationContract]
        bool updateProblem1(int uid, int patientID, string description, int severity, string notes);

        [OperationContract]
        bool updateProblem2(int uid, int patientID, string description, string notes);

        [OperationContract]
        bool createProblem(int patientID, string joint, string problems, string description, int severity, string notes);

        [OperationContract]
        List<problem> retrievePatientProblems(int patientID);

        [OperationContract]
        bool deleteProblems(int uid);

        #endregion

        #region CRUD for patient

        [OperationContract]
        int addNewPatient(string lastName, string firstName, string title, DateTime dOB, string gender, string country, string address1, string address2, string postalCode, string homePhone, string workPhone, string mobile, string email, string doctor, string NOKName, string NOKAddress1, string NOKAddress2, string NOKPostalCode, string NOKphoneNumber);

        [OperationContract]
        List<patient> retrieveAllOwnPatients(string docname);

        [OperationContract]
        int retrieveNumofOthPatients(string docname);

        [OperationContract]
        List<patient> retrieveAllOthPatients(string docname);

        [OperationContract]
        int retrieveNumofOwnPatients(string docname);

        [OperationContract]
        patient retrievePatient(int uid);

        #endregion

        # region CRUD for gamePlay

        [OperationContract]
        bool createNewGamePlay(int sessionID, int stageID, string joint, string specialInstructions, string gameKey, string gameValue);

        [OperationContract]
        List<gamePlay> retrieveAllGamePlay();

        [OperationContract]
        List<gamePlay> retrieveAllGamePlayofSession(int sessionID);

        [OperationContract]
        List<gamePlay> retrieveAllGamePlayofSessionAndStage(int sessionID, int stageID);

        [OperationContract]
        gamePlay retrieveGamePlay(int gamePlayID);

        [OperationContract]
        List<KeyValuePair<string, string>> getOldestUID(int exeID, int patientID);

        //[OperationContract]
        //List<gamePlay> retrievePatientAllGamePlay(int patientID);

        //[OperationContract]
        //List<gamePlay> retrievePatientJointGamePlay(int patientID, int joint);

        //[OperationContract]
        //List<gamePlay> retrievePatientJointGamePlayByEXE(int patientID, int joint, int exeID);

        //[OperationContract]
        //List<gamePlay> retrievePatientMostRecentGamePlay(int patientID, int number);

        //[OperationContract]
        //List<gamePlay> retrievePatientGamePlayofaEXE(int patientID, int exeID);

        #endregion

        # region CRUD for Tag

        [OperationContract]
        string retrieveJointName(string joint);

        # endregion

        # region CRUD for exeType

        [OperationContract]
        string retrieveExeTypeDescription(int exeType);

        #endregion

        #region CRUD for patient_exe

        [OperationContract]
        int retrieveExeIDAssignedtoPatient(int exe, int patient, DateTime dateassigned);

        [OperationContract]
        List<EXE> retrieveExeAssignedtoPatient(int patientID);

        [OperationContract]
        bool deleteExeAssignedtoPatient(int uid);

        [OperationContract]
        bool createExeAssingedtoPatient(int patientID, List<EXE> exeList);

        #endregion

        # region CRUD for session

        [OperationContract]
        int createNewSession(int patientID, int exeID);

        [OperationContract]
        int retrieveMostRecentSessionIDOfPatientofExe(int patientID, int exeID);

        [OperationContract]
        List<session> retrieveSessionOfPatient(int patientID);

        [OperationContract]
        List<session> retrieveSessionOfPatientofExe(int patientID, int exeID);

        [OperationContract]
        List<session> retrieveSession(int sessionID);

        #endregion

        # region CRUD for exe_stage

        [OperationContract]
        List<stage> retrieveExeStage(int exeID);

        #endregion

        #region retrieve_exe_custKey
        [OperationContract]
        void create_exe_custKey(List<string> custKey, int exe);
        [OperationContract]
        List<string> retrieve_exe_custKey(int exeID);

        #endregion

        #region retrieve_patient_exe_custKey
        [OperationContract]
        bool createPatientExeCustkey(List<KeyValuePair<string, string>> settingsList, int patient_exe_id);
        [OperationContract]
        List<KeyValuePair<string, string>> retrieve_patient_exe_custKey(int patient_exe_id);

        #endregion

        # region CRUD stage
        [OperationContract]
        string retrieve_stageName(int stageID);

        #endregion

        #region generate report
        [OperationContract]
        string retrieveUserNotes(string joint, int patientID, int exeID);
        [OperationContract]
        List<gamePlay> generateNotes(string joint, int patientID, int exeID);


        #endregion

        #region CRUD place
        [OperationContract]
        string retrieve_place(int placeID);

        #endregion

        #region score
        [OperationContract]
        List<highScore> retrieveHighScore(int exeID, int difficulty);

        [OperationContract]
        int retrievePersonalHighScore(int patientID, int exeID, int difficulty);
        #endregion

        #region loginPatient and teleRehab
        [OperationContract]
        string loginPatient(string username, string password);

        [OperationContract]
        int getPatientUID(string email);

        [OperationContract]
        List<KeyValuePair<string, string>> getLatestUID(int exeID, int patientID);

        [OperationContract]
        List<double> getLatestAngle(int exeID, int patientID, int jointID, string axis);
        #endregion

        #region web usage
        [OperationContract]
        string[] siteLoginPatient(string username, string password);
        #endregion
    }
}